package kr.ac.konkuk.dblab.point.quadtree;

import java.awt.geom.Point2D;

import kr.ac.konkuk.dblab.point.metadata.Rect;

public abstract class AbstractNode implements Node {
	private CompositeNode parent = null;
	private boolean leaf;
	private NodeType type = null;
	private int degree;
	private Rect rect;
	private Point2D center;
	
	public AbstractNode(NodeType type, boolean leaf, int degree) {
		this.type = type;
		this.leaf = leaf;
		this.degree = degree;
	}
	
	public Rect rect(Rect rect) {
		Rect t = this.rect;
		this.rect = rect;
		return t;
	}
	
	public Point2D center(Point2D center) {
		Point2D t = this.center;
		this.center = center;
		return t;
	}
	
	public Rect rect() {
		return rect;
	}
	
	public Point2D center() {
		return center;
	}
	
	public int degree() {
		return degree;
	}
	
	public NodeType type() {
		return type;
	}
	
	public boolean isLeaf() {
		return leaf;
	}
	
	public CompositeNode parent() {
		return parent;
	}
	
	public CompositeNode parent(CompositeNode parent) {
		CompositeNode p = this.parent ;
		this.parent = parent;
		this.degree = parent.degree() + 1;
		
		return p;
	}
}
